﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class StudentNonAcad_AllStudentNonAcadInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MaintainScrollPositionOnPostBack = true;
        if (!IsPostBack)
        {
            FillStudentNonAcadLoadInGrid();
        }
    }
    #region CourseRegistrationDataBase Calls
    private DataTable FetchAllStudentNonAcadLoadInfo()
    {
        string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
        SqlConnection conn = new SqlConnection(connStr);
        SqlDataAdapter dAd = new SqlDataAdapter();
        SqlCommand dCmd = new SqlCommand();
        DataTable dTable = new DataTable();
        try
        {
            dCmd.CommandText = "StudentNonAcadWorkLoadSelectAll";
            dCmd.CommandType = CommandType.StoredProcedure;
            dCmd.Connection = conn;
            dAd.SelectCommand = dCmd;
            // now open the connection
            conn.Open();
            dAd.Fill(dTable);
            conn.Close(); // close the connection

            return dTable;
        }
        catch (Exception e)
        {
            throw e;
        }

        finally
        {
            dCmd.Clone();
            dAd.Dispose();
            conn.Dispose();
        }
    }
    
    #endregion
    private void FillStudentNonAcadLoadInGrid()
    {
        try
        {
            DataTable dTable = FetchAllStudentNonAcadLoadInfo(); ;
            if (dTable.Rows.Count > 0)
            {
                StudentNonAcadInfoGridView.DataSource = dTable;
                StudentNonAcadInfoGridView.DataBind();
            }
            else
            {
                dTable.Rows.Add(dTable.NewRow());
                StudentNonAcadInfoGridView.DataSource = dTable;
                StudentNonAcadInfoGridView.DataBind();
                int TotalColumns = StudentNonAcadInfoGridView.Rows[0].Cells.Count;
                StudentNonAcadInfoGridView.Rows[0].Cells.Clear();
                StudentNonAcadInfoGridView.Rows[0].Cells.Add(new TableCell());
                StudentNonAcadInfoGridView.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                StudentNonAcadInfoGridView.Rows[0].Cells[0].Text = "No Record Found";
                Master.MasterMessageBoxText = Master.MasterMessageBoxText + "Operation Completed Sucessfully";
            }
        }
        catch (Exception e)
        {
            Master.MasterMessageBoxText = Master.MasterMessageBoxText + "--ERROR: " + e.Message;
        }
    }
}